package com.itheima.redbaby.engine.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import com.alibaba.fastjson.JSON;
import com.itheima.redbaby.GloableParams;
import com.itheima.redbaby.bean.AddressCheckOutInfo;
import com.itheima.redbaby.bean.CheckAddUp;
import com.itheima.redbaby.bean.CheckoutProm;
import com.itheima.redbaby.bean.DeliveryInfo;
import com.itheima.redbaby.bean.OrderInfo;
import com.itheima.redbaby.bean.PaymentInfo;
import com.itheima.redbaby.bean.Product;
import com.itheima.redbaby.engine.CheckOutEngine;
import com.itheima.redbaby.engine.OrderSumbitEngine;
import com.itheima.redbaby.net.HttpUtil;

public class OrderSumbitEngineImpl implements OrderSumbitEngine {
	@Override
	public OrderInfo getServerOrderinfo() {
		//1.读取response字段
		//2.判断是否为 checkout
		HttpUtil httpUtil=new HttpUtil();
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("response", "ordersumbit");
		String userid=null;
		String json = httpUtil.sendPost(GloableParams.LZLURLCOMMON+GloableParams.LZLCONTENT, params, userid);
		try{
			JSONObject jsonObject=new JSONObject(json);
			String res = jsonObject.getString("response");//得到解析中的response信息
			if(res.equals("ordersumbit")){
				String orderinfo = jsonObject.getString("orderinfo");
				OrderInfo orderInfo = (OrderInfo) JSON.parse(orderinfo);
				return orderInfo;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}//相当于服务器中map集合
		return null;
	}
}
